/*
 * @Author: 徐建辰
 * @Date: 2022-04-26 14:10:19
 * @LastEditTime: 2022-04-26 14:14:16
 * @LastEditors: 徐建辰
 * @Description: 获取全局app配置
 */
import {ref, computed, watch} from 'vue'
import useConfigStore from '@/store/config'

export default function useAppConfig() {
  const configStore = useConfigStore()
  const headerMarginLeft = ref(0)

  /* computed */
  const isMobile = computed(() => configStore.isMobile)
  const layout = computed(() => configStore.layout)
  const collapse = computed(() => configStore.collapse)

  /* watch */
  watch(
    () => configStore.collapse, 
    newVal => {
      if (newVal) headerMarginLeft.value = 64
      else headerMarginLeft.value = 210
    }, 
    {
      deep: true,
      immediate: true
    }
  )

  return {isMobile, layout, collapse, headerMarginLeft}
}